package dome1;

import java.util.*;

public class Text {
    public static void main(String[] args) {
        Set<String> set = new TreeSet<>();
        set.add("hello");
        set.add("abc");
        set.add("world");
        System.out.println(set);
//        for(String s : set) {
//            System.out.println(s);
//        }

        Iterator<String> iterator = set.iterator();
        while(iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
    public static void main2(String[] args) {
        //根据K的值 来判断大小
        Map<String,Integer> map = new TreeMap<>();
        map.put("hello",13);
        map.put("abc",2);
        map.put("world",5);
//        System.out.println(map.get("abc"));

        Set<String> strings = map.keySet();
        System.out.println(strings);

        Collection<Integer> values = map.values();
        System.out.println(values);

        //这是把Map转化成Set的方法
        Set<Map.Entry<String, Integer>> set = map.entrySet();

        for(Map.Entry<String,Integer> entry : set) {
            System.out.println("Key : " + entry.getKey() + "  Value : " + entry.getValue());
        }

    }

    public static void main1(String[] args) {
        BinarySearchTree binarySearchTree = new BinarySearchTree();
        binarySearchTree.insert(4);
        binarySearchTree.insert(1);
        binarySearchTree.insert(2);
        binarySearchTree.insert(6);
        binarySearchTree.remove(4);
    }
}
